﻿using UnityEditor;
using UnityEditor.UI;
using UnityEngine;

namespace BToolkit
{
    [CustomEditor(typeof(CircleImage))]
    public class CircleImageEditor : ImageEditor
    {
        CircleImage circleImage;

        protected override void OnEnable()
        {
            base.OnEnable();
            circleImage = (CircleImage)target;
        }

        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();

            circleImage.detail = EditorGUILayout.IntField("Detail", circleImage.detail);
            if (circleImage.detail < 3) circleImage.detail = 3;
            if (circleImage.detail > 100) circleImage.detail = 100;

            circleImage.texScale = EditorGUILayout.FloatField("Tex Scale", circleImage.texScale);
            if (circleImage.texScale < 0) circleImage.texScale = 0;

            if (GUI.changed)
            {
                serializedObject.ApplyModifiedProperties();
                EditorUtility.SetDirty(target);
                circleImage.SetAllDirty();
            }
        }
    }
}